package com.hs.chd.dwr;

import java.util.List;
import java.util.Map;

import com.hs.core.db.DBMgr;
import com.hs.core.dwr.DwrHelper;
import com.hs.core.utils.TimeUtil;

public class SummarizeHelper  extends DwrHelper{
	 
    /**
     * 查询综述二级分类内容
     * @param disid
     * @param catatype
     * @return
     */
	public String querySummBydisid(String disid,String catatype){
 		String content = "";
 		String updatestr = "";
 		String summid = "";
		String sql = "select id,SUMMCONTENT,UPDATEDATE from SCHD_TCM_SUMM where tcmid=? and CATAGORYID=?";
      	List datalist =	this.getDbo().queryList(sql, new Object[]{disid,catatype});
      	if(datalist.size() > 0){
      		Map map = (Map)datalist.get(0);
      		System.out.println("222:" + map);
      		content = (String)map.get("SUMMCONTENT");
      		updatestr = (String)map.get("UPDATEDATE");
      		summid =  map.get("ID") +"";
      	} 
      	System.out.println("111:" + summid+"#"+content+"#"+updatestr);
		return summid+"#"+content+"#"+updatestr;
	}
	/**
	 * 新增综述内容
	 * @param disid
	 * @param catatype
	 * @param content
	 * @return
	 */
	public String insertSummContent(String disid,String catatype,String content){
		String seqid = this.getSeqValue("SEQ_SCHD_TCM_SUMM_ID"); 
		String datetime = TimeUtil.getCurrentDateTime();
		String sql = "insert into SCHD_TCM_SUMM(ID, TCMID, CATAGORYID,SUMMCONTENT,UPDATEDATE,STATUS) VALUES(?,?,?,?,?,0)";
      	int count =	this.getDbo().update(sql, new Object[]{seqid,disid,catatype,content,datetime});
      	return seqid+"#"+datetime;
	}
	/**
	 * 提交综述内容
	 * @param disid
	 * @param catatype
	 * @param content
	 * @return
	 */
	public String submitSummContent(String summid){
 		String sql = "update SCHD_TCM_SUMM set status=1 where id=?";
      	int count =	this.getDbo().update(sql, new Object[]{summid});
      	return "";
	}
	
	
	/**
	 * 新增综述内容
	 * @param disid
	 * @param catatype
	 * @param content
	 * @return
	 */
	public String updateSummContent(String summid,String content){
 		String sql = "update SCHD_TCM_SUMM set SUMMCONTENT=?,UPDATEDATE=? where id=?";
 		String datetime = TimeUtil.getCurrentDateTime();
      	int count =	this.getDbo().update(sql, new Object[]{content,datetime,summid});
      	return summid+"#"+datetime;
	}
}
